/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ipo.mm.web.formbeans;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.ipo.mm.ejb.entities.InstitutionFamily;

/**
 *
 * @author predrag
 */
public class FamilyBean extends org.apache.struts.validator.ValidatorForm {
    
    private String name;
    private String note;
    private String submit;

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = super.validate(mapping, request);

        return errors;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    

    /**
     * @return the note
     */
    public String getNote() {
        return note;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setNote(String note) {
        this.note = note;
    }

   
    /**
     * @return the submit
     */
    public String getSubmit() {
        return submit;
    }

    /**
     * @param submit the submit to set
     */
    public void setSubmit(String submit) {
        this.submit = submit;
    }

    @Override
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        super.reset(mapping, request);

        String method = request.getParameter("method");

        if ("showUpdateFamilyForm".equals(method) || "viewFamilyForm".equals(method)) {
            InstitutionFamily family = (InstitutionFamily) request.getSession().getAttribute("updateFamily.family");

            this.setName(family.getName());
            this.setNote(family.getNote());

        }
    }
}
